package users

import (
	"gitee.com/xgotool/backend-framework-template/config"
	"gitee.com/xgotool/backend-framework-template/model"
)

// 获取用户ID
//
//	uname 用户名
func GetId(uname string) (uint, error) {
	conn, err := config.GetConnect()
	if err != nil {
		return 0, err
	}
	mod := model.User{}
	err = conn.Table(mod.TableName()).Select("id").Where("user_name", uname).Find(&mod).Error
	if err != nil {
		return 0, err
	}
	return mod.Id, nil
}
